<template>
  <HomePanel title="新鲜好物" sub-title="新鲜出炉 品质靠谱" ref="target">
    <template #right>
      <XtxMore />
    </template>
    <template #content>
      <Transition name="fade">
        <ul v-if="result.length" class="goods-list">
          <li v-for="item in result" :key="item.id">
            <RouterLink :to="`/product/${item.id}`">
              <img v-lazy="item.picture" alt="">
              <p class="name">{{ item.name }}</p>
              <p class="price">&yen;{{ item.price }}</p>
            </RouterLink>
          </li>
        </ul>
        <HomeSkeleton bg="#f0f9f4" v-else />
      </Transition>
    </template>
  </HomePanel>
</template>
<script lang="ts" setup>
import { findNew } from '../../api/home'
import HomePanel from './home-panel.vue';
import HomeSkeleton from './home-skeleton.vue'
import { useLazyData } from '../../hooks'
const { target, result } = useLazyData(findNew)

</script>
<style lang="less" scoped>
@import '../../assets/styles/mixins.less';
@import '../../assets/styles/variables.less';

.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;

  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    .hoverShadow();

    img {
      width: 306px;
      height: 306px;
      object-fit: cover;
    }

    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }

    .name {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis
    }

    .price {
      color: @priceColor;
    }
  }
}
</style>